//
//  ZYCAttendanceStatusStatisticsView.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/27.
//

#import "ZYCAttendanceStatusStatisticsView.h"
#import "ZYCAttendanceStatusGroupView.h"
#import "ZYCAttendanceStatisticsModel.h"

@interface ZYCAttendanceStatusStatisticsView ()



@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *noramlGroupView;
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *lateGroupView;
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *leaveGroupView;
@property (nonatomic, strong) ZYCAttendanceStatusGroupView *absentlGroupView;
@end

@implementation ZYCAttendanceStatusStatisticsView
- (void)setCountZC:(NSString *)countZC{
    _countZC = countZC;
    _noramlGroupView.title = @"正常";
    _noramlGroupView.count = countZC;
}
- (void)setCountCD:(NSString *)countCD{
    _countCD = countCD;
    _lateGroupView.title = @"迟到";
    _lateGroupView.count = countCD;
}
- (void)setCountQJ:(NSString *)countQJ{
    _countQJ = countQJ;
    _leaveGroupView.title = @"请假";
    _leaveGroupView.count = countQJ;
}

- (void)setCountWD:(NSString *)countWD{
    _countWD = countWD;
    _absentlGroupView.title = @"未到";
    _absentlGroupView.count = countWD;
}

- (void)setModel:(ZYCAttendanceStatisticsModel *)model{
    _model = model;
    _noramlGroupView.title = @"正常";
    _noramlGroupView.count = model.countZC;
    
    _lateGroupView.title = @"迟到";
    _lateGroupView.count = model.countCD;
    
    _leaveGroupView.title = @"请假";
    _leaveGroupView.count = model.countQJ;
    
    _absentlGroupView.title = @"未到";
    _absentlGroupView.count = model.countWD;
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.bgView];
        [self.bgView addSubview:self.noramlGroupView];
        [self.bgView addSubview:self.lateGroupView];
        [self.bgView addSubview:self.leaveGroupView];
        [self.bgView addSubview:self.absentlGroupView];
 
        CGFloat margin  = (kScreenWidth - 20 - 50 * 4) / 5;
        
        [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(self).offset(10.0f);
            make.bottom.right.equalTo(self).offset(-10.0f);
        }];
        
        
        [self.noramlGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.bgView).offset(margin);
            make.centerY.equalTo(self.bgView);
        }];
        
        [self.lateGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.noramlGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.bgView);
        }];
        
        [self.leaveGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.lateGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.bgView);
        }];
        [self.absentlGroupView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(50, 70));
            make.left.equalTo(self.leaveGroupView.mas_right).offset(margin);
            make.centerY.equalTo(self.bgView);
        }];
    }
    return self;
}

- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = HEX_RGB(kBgWhiteColor);
        _bgView.layer.cornerRadius = 7.5f;
        _bgView.layer.masksToBounds = YES;
    }
    return _bgView;
}

- (ZYCAttendanceStatusGroupView *)noramlGroupView {
    if (!_noramlGroupView) {
        _noramlGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _noramlGroupView.color = HEX_RGB(@"#39A85B");
    }
    return _noramlGroupView;
}

- (ZYCAttendanceStatusGroupView *)lateGroupView {
    if (!_lateGroupView) {
        _lateGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _lateGroupView.color = HEX_RGB(@"#E93C06");
    }
    return _lateGroupView;
}

- (ZYCAttendanceStatusGroupView *)leaveGroupView {
    if (!_leaveGroupView) {
        _leaveGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _leaveGroupView.color = HEX_RGB(@"#FDA252");
    }
    return _leaveGroupView;
}

- (ZYCAttendanceStatusGroupView *)absentlGroupView {
    if (!_absentlGroupView) {
        _absentlGroupView = [[ZYCAttendanceStatusGroupView alloc] init];
        _absentlGroupView.color = HEX_RGB(@"#B9B9B9");
    }
    return _absentlGroupView;
}
@end
